package com.saac.imf;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;

@SpringBootApplication
@EnableWs
public class CaacMqApplication {

    public static void main(String[] args) {
        SpringApplication.run(CaacMqApplication.class, args);
    }

    @Bean
    public MessageDispatcherServlet messageDispatcherServlet() {
        return new MessageDispatcherServlet();
    }

    @Bean(name = "uploadService")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema uploadServiceSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("UploadServicePort");
        wsdl11Definition.setLocationUri("/ws");
        wsdl11Definition.setTargetNamespace("http://localhost:8081/");
        wsdl11Definition.setSchema(uploadServiceSchema);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema uploadServiceSchema() {
        return new SimpleXsdSchema(new ClassPathResource("uploadservice.xsd"));
    }
}
